package com.wjv.example.controller;

import com.wjv.example.common.entity.ResultInfo;
import com.wjv.example.service.PaymentFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * <p>Title: OrderController</p>
 * <p>Company:misspao </p>
 *
 * @author: wjv
 * @Date: Create in 15:06 2020/9/22
 * @Description:
 */
@RestController
@RequestMapping("/consumer/order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    private final static String url = "http://localhost:8001";

    private final static String url2 = "http://CLOUD-PROVIDER-PAYMENT";

    @GetMapping("/get")
    public ResultInfo get(int id) {
        return restTemplate.getForObject(url2 + "/payment/getPayment?id=" + id, ResultInfo.class);
    }

    @Autowired
    private PaymentFeignService paymentFeignService;

    @GetMapping("/getFeign")
    public ResultInfo getFeign(int id) {
        return paymentFeignService.getPayment(id);
    }
}
